package example;

interface ShapeArea
{
    double getArea();
    double getPerimeter();
}
class MyRectangle implements ShapeArea
{
    private double width;
    private double height;
    public MyRectangle(double w,double h)
    {
        width = w;
        height = h;
    }
    public double getArea()
    {
        return width*height;
    }
    public double getPerimeter()
    {
        return (width + height)*2;
    }
    public String toString()
    {
        return "width=" + width + ",height=" + height + ",perimeter=" + this.getPerimeter()
                +",area=" + this.getArea();
    }
}
class MyTriangle implements ShapeArea
{
    private double a,b,c,s;
    MyTriangle(double x,double y,double z)
    {
        a = x;
        b = y;
        c = z;
        s = (x + y + z)/2;
    }
    public double getArea()
    {
        return Math.sqrt(s*(s-a)*(s-b)*(s-c));
    }
    public double getPerimeter()
    {
        return 2*s;
    }
    public String toString()
    {
        return "three sides:" + a + ","+ b + "," + c + ",perimeter=" + this.getPerimeter()
                +",area=" + this.getArea();
    }
}
public class Test {
    public static void main(String[] args) {
        MyRectangle r = new MyRectangle(1,2);
        System.out.println(r.toString());
        MyTriangle t = new MyTriangle(3,4,5);
        System.out.println(t.toString());
    }
}
